//
//  OpacityFeedbackButton.swift
//  PMS
//
//  Created by haotianz on 16/8/22.
//  Copyright © 2016年 途家. All rights reserved.
//

import Foundation


public class OpacityFeedbackButton: UIButton {
    public init() {
        super.init(frame: CGRect.zero)
        
        addTarget(self, action: #selector(OpacityFeedbackButton.setBackgroundColorForTouchDown), for: .touchDown)
        addTarget(self, action: #selector(OpacityFeedbackButton.setBackgroundColorForTouchUp), for: .touchUpInside)
        addTarget(self, action: #selector(OpacityFeedbackButton.setBackgroundColorForTouchUp), for: .touchUpOutside)
        addTarget(self, action: #selector(OpacityFeedbackButton.setBackgroundColorForTouchUp), for: .touchCancel)
    }
    
    required public init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    @objc func setBackgroundColorForTouchDown() {
        alpha = 0.5
    }
    
    @objc func setBackgroundColorForTouchUp() {
        alpha = 1
    }
}
